package com.battery.controller;


import com.battery.pojo.Feedback;
import com.battery.service.FeedbackService;
import com.battery.util.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@Api(tags = "反馈相关操作")
public class FeedbackController {

    @Autowired
    FeedbackService fds;

    @PostMapping("/getAllFeedback")
    @ResponseBody
    @CrossOrigin
    @ApiOperation("获取所有反馈")
    public Result getAllFeedback(){

        Result result = fds.getAllFeedback();
        return result;

    }

    @PutMapping("/updateFeedback")
    @ResponseBody
    @CrossOrigin
    @ApiOperation("更新某一反馈状态")
    public Result updateFeedback(@RequestBody @ApiParam(name = "传入更改后的反馈内容" ,value="传入json", required = true) Feedback feedback){
        System.out.println(feedback);
        Result result = fds.updateFeedbackStatus(feedback);
        return result;
    }

    @DeleteMapping("/deleteFeedback")
    @ResponseBody
    @CrossOrigin
    @ApiOperation("删除某一反馈")
    public Result deleteFeedback(@ApiParam(name = "传入需要删除的反馈id" ,value="传入int")int id){
        Result result = fds.deleteFeedback(id);
        return result;
    }

    @GetMapping("/selectFeedback")
    @ResponseBody
    @CrossOrigin
    @ApiOperation("条件筛选反馈")
    public Result selectFeedback(@ApiParam(name = "传入筛选条件",value="传入String条件")String keyword){
        Result result = fds.selectFeedback(keyword);
        return result;
    }



}
